/**
 * 
 */
package galaxy.drawer;

import java.util.Collection;

import galaxy.drawer.drawable.Drawable;
import galaxy.generator.Node;
import processing.core.PApplet;
import processing.core.PVector;

public class Context
{
	final public PApplet applet;
	final public Collection<Drawable> drawables;
	public PVector pos;
	public PVector delta = new PVector();
	public float angle;
	public Node node;
	
	public Context(PApplet applet, Collection<Drawable> drawables, PVector position, float angle)
	{
		this.applet = applet;
		this.drawables = drawables;
		this.pos = position;
		this.angle = angle;
	}
	
	public Context setNode(Node n)
	{
		node = n;
		return this;
	}
	
	public Context addDrawable(Drawable d)
	{
		drawables.add(d);
		return this;
	}
	
	public Context setDelta(PVector delta)
	{
		this.delta = delta;
		return this;
	}
	
	public Context setPosition(PVector pos)
	{
		setDelta(PVector.sub(pos, this.pos));
		this.pos = pos;
		return this;
	}
	
	public Context clone()
	{
		return new Context(applet, drawables, pos.get(), angle)
			.setNode(node)
			.setDelta(delta.get());
	}
}